﻿using ProjectFootball.MVC.Foundation;
using ProjectFootball.MVC.Foundation.ResourceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Security.Principal;

namespace ProjectFootball.MVC.Models.EntityFramework.Entities
{
    public class Competition : BaseApprovableEntity, IApprovableEntity
    {
        #region Constructors
        public Competition()
        {
            Campaigns = new HashSet<Campaign>();
        }

        public Competition(IPrincipal user, CreateType createType, Guid approvalGuid, string competitionName, CompetitionType competitionType, LocationType locationType, Guid? countryGuid, DateTime activeFrom, DateTime activeTo)
            :base(user, createType, approvalGuid)
        {
            CompetitionName = competitionName;
            CompetitionType = competitionType;
            LocationType = locationType;
            CountryGuid = countryGuid;
            ActiveFrom = activeFrom;
            ActiveTo = activeTo;
        }
        #endregion

        [StringLength(50)]
        [Required]
        public string CompetitionName { get; set; }

        public CompetitionType CompetitionType { get; set; }

        public LocationType LocationType { get; set; }

        [ForeignKey("Country")]
        public Guid? CountryGuid { get; set; }

        public DateTime ActiveFrom { get; set; }

        public DateTime ActiveTo { get; set; }

        [ForeignKey("CountryGuid")]
        public virtual Country Country { get; set; }

        [ForeignKey("CompetitionGuid")]
        public virtual ICollection<Campaign> Campaigns { get; set; }
    }
}